package com.xingchi.tornado.generator.config;

import com.baomidou.mybatisplus.generator.config.builder.CustomFile;
import lombok.Data;
import lombok.experimental.SuperBuilder;

/**
 * 基础配置
 *
 * @author xingchi
 * @date 2024/4/2 22:31
 */
@Data
@SuperBuilder
public abstract class BaseConfig {

    /**
     * 模板路径
     */
    private String templatePath;

    /**
     * 包路径
     */
    private String packageName;

    /**
     * 自定义继承的Entity类全称，带包名
     */
    private Class<?> superClass;

    /**
     * 是否覆盖已有文件（默认 false）
     */
    private boolean fileOverride;

    public CustomFile render(String entityName) {
        CustomFile.Builder builder = new CustomFile.Builder()
                .fileName(getFileName(entityName))
                .templatePath(templatePath)
                .packageName(packageName)
                .enableFileOverride();
        if (fileOverride) {
            builder.enableFileOverride();
        }

        return builder.build();
    }

    public abstract String getFileName(String entityName);

}
